<div class="location-0" id="content">
    <div id="content-box">

        <div class="work">
            <div class="location loc-1">
                <div id="basket-detail">
                    <div class="reservation reservation-3">
                        <h2>Booking Summary</h2>

                        <div class="box">
                            <h3><?=$car[0]->name?> <small>or similar </small></h3>


                            <table width="100%" border="0" class="clean-tab">
                                <tbody>
                                    <tr>
                                        <td valign="top">
                                            <h4>Pick up</h4>
                                            <ul class="clean-list" id="fromData">

                                                <li><?=$this->session->userdata('pickup_loc_text')?></li>
                                                <li><?=$this->session->userdata('pickup_date').', '.$this->session->userdata('fullfrom');?> h</li>
                                                <li><strong>&nbsp;</strong></li>
                                            </ul>
                                        </td>
                                        <td valign="top">
                                            <h4>Return</h4>
                                            <ul class="clean-list" id="destData">
                                                <li><?=$this->session->userdata('return_loc_text')?></li>
                                                <li><?=$this->session->userdata('return_date').', '.$this->session->userdata('fullto');?> h</li>
                                                <li><strong>&nbsp;</strong></li>
                                            </ul>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td valign="top">
                                            <ul class="clean-list">
                                                <li>
                                                    <?if(!isset($ac_numrows)){?>
                                                        <div class="submit submit-plus">

                                                            <div class="submit-end">&nbsp;</div>
                                                            <a id="button-extras" href="#" title="Optional accessories" onclick="popup_box({url: base_url+'rentacar/show_accessories/'+'<?=$car[0]->id?>'});return false;">Optional accesories</a>
                                                        </div>
                                                        <?}?>
                                                    <div id="accessories_preview" style="display: none;">
                                                        <ul>
                                                            <?
                                                                $html = '';
                                                                if($this->session->userdata('extras')){
                                                                    foreach($accessories as $row1){

                                                                        foreach($this->session->userdata('extras') as $val){

                                                                            if($row1->id==$val){
                                                                                $html.='<li>';
                                                                                $html.='<strong class="green-text">'.$row1->type.'</strong>';
                                                                                $html.='<br />';
                                                                                $html.='<small>price: '.$row1->price.' &euro; / day</small>';
                                                                                $html.='</li>';                                        

                                                                            }

                                                                        }

                                                                    }
                                                                }
                                                                echo $html;

                                                                if($html!='')?><script type="text/javascript">$('#accessories_preview').show();</script><?
                                                            ?>
                                                        </ul>
                                                    </div>

                                                </li>

                                            </ul></td>
                                    </tr>
                                </tbody>
                            </table>

                            <big>
                                <strong><span class="green-text">Final price:</span> <span id="final_price"><?=$this->session->userdata('tot_price');?></span> &euro;</strong>
                            </big><br>


                            <p>
                                <strong>Price includes:</strong> <?=$car[0]->description?>


                            </p></div>

                        <div class="image-box left">
                            <a rel="lightbox" title="<?=$car[0]->name?>" href="<?=$info_sis_url.$car[0]->url?>_800_600.jpg">
                                <img alt="<?=$car[0]->name?>" src="<?=$info_sis_url.$car[0]->url?>_105_76.jpg">
                            </a>
                        </div>
                        <div class="submit">
                            <div class="submit-end">&nbsp;</div>
                            <a title="Change car" href="<?=$url?>step_2">Change car</a>
                        </div>
                    </div>
                </div>

                <form id="formReservationStep3" method="post" action="<?=$url?>rentacar/process_booking">
                    <input type="hidden" value="1" name="newsletter" id="newsletter">

                    <div id="formReservationStep3h1" class="fieldset formReservationStep3h1"><fieldset>
                            <legend><span>Contact Information</span></legend><div class="fieldset-box">

                                <dl class="formitem-name formitem">
                                    <dt><label class="element" for="name"><b class="required">*</b>Name and surname</label> </dt>
                                    <dd><input type="text" value="" name="name" id="name" class="text"></dd>
                                </dl>

                                <dl class="formitem-phone formitem"
                                    ><dt><label class="element" for="phone"><b class="required">*</b>Telephone</label> </dt>
                                    <dd><input type="text" value="" name="phone" id="phone" class="text"></dd>
                                </dl>

                                <dl class="formitem-email formitem"><dt><label class="element" for="email"><b class="required">*</b>E-mail</label> </dt>
                                    <dd><input type="text" value="" name="email" id="email" class="text"></dd>
                                </dl>

                                <dl class="formitem-notice formitem">
                                    <dt><label class="element" for="notice">Note</label> </dt>
                                    <dd><textarea name="notice" id="notice"></textarea></dd>
                                </dl>

                                <dl class="formitem-qf_f2eff2 formitem">
                                    <dt><label class="element"><b class="required">*</b>I agree with 
                                        <a href="#" id="terms-link" onclick="popup_box({url: base_url+'rentacar/show_terms'});return false;">Terms and Conditions</a>&nbsp;</label> </dt>
                                    <dd><input type="checkbox" id="qf_f2eff2" value="1" name="termsOfTradeAcceptance" class="checkbox"></dd>
                                </dl>

                                <dl class="formitem-formReservationStep3Submit formitem">
                                    <dt><label class="element" for="formReservationStep3Submit">&nbsp;</label> </dt>
                                    <dd><input type="submit" value="Book now" name="formReservationStep3Submit" id="formReservationStep3Submit" class="submit"></dd>
                                </dl>

                                Customer must present his valid driver's license and ID card or passport by the pick-up.

                                <dl class="reqnote formitem"><dd>
                                        <span class="quick-form-required-note-asterisk">*</span>
                                        <span class="quick-form-required-note-text">Required field</span>
                                    </dd>
                                </dl>

                                <dl>
                                    <dd>
                                        Please note: Globtour Montenegro will never sell, share or distribute your personal information.
                                    </dd>
                                </dl>

                            </div></fieldset></div>
                </form>

            </div>
        </div> <!-- END .work -->

    </div> <!-- END #content-box -->
</div>

<?if(isset($car_bigger)){?>

    <div class="location-0" id="column">

        <div id="formReservationBasicDatahPreview" class="fieldset formReservationBasicDatahPreview box">
            <fieldset>
                <legend><span>Upgrade for a bigger car</span></legend>

                <div class="item-box">
                    <h3><a title="<?=$car_bigger[0]->name?>" href="<?=$url?>details?id=<?=$car_bigger[0]->id?>"><?=$car_bigger[0]->name?></a></h3>
                    <div class="image-box left">
                        <a title="<?=$car_bigger[0]->name?>" href="<?=$url?>details?id=<?=$car_bigger[0]->id?>">

                            <img alt="<?=$car_bigger[0]->name?>" src="<?=$info_sis_url.$car_bigger[0]->url?>_105_76.jpg" width="90px">

                        </a>
                    </div>
                    <div class="annotation">
                        <?=$car_bigger[0]->description?>
                    </div>
                    <!-- vlastnosti - sedy box -->
                    <!-- vlastnosti - sedy box -->
                    <div class="itemCar-properties">
                        <ul class="clean-list">

                            <li title="seat count" class="param-seatCount">
                                <div class="param-title">seat count: </div>
                                <div class="param-int"><?=$car_bigger[0]->seat_count?></div>
                            </li>

                            <li title="Number of doors" class="param-doorCount">
                                <div class="param-title">Number of doors: </div>
                                <div class="param-int"><?=$car_bigger[0]->num_of_doors?></div>
                            </li>

                            <li title="luggage space capacity" class="param-bootCapacity">
                                <div class="param-title">luggage space capacity: </div>
                                <div class="param-int"><?=$car_bigger[0]->luggage_capacity?></div>
                            </li>

                            <li title="A/T" class="param-autoTransmission">
                                <div class="param-title">A/T: </div>
                                <?if($car_bigger[0]->auto_transmission){?>
                                    <div class="param-boolean-true"><span>yes</span></div>
                                    <?}else{?>
                                    <div class="param-boolean-false"><span>no</span></div>   
                                    <?}?>
                            </li>

                            <li title="A/C" class="param-airCondition">
                                <div class="param-title">A/C: </div>
                                <?if($car_bigger[0]->ac){?>
                                    <div class="param-boolean-true"><span>yes</span></div>
                                    <?}else{?>
                                    <div class="param-boolean-false"><span>no</span></div>   
                                    <?}?>
                            </li>

                            <li title="benzin" class="param-fuel last">
                                <div class="param-title">A/C: </div>
                                <?if($car_bigger[0]->diesel){?>
                                    <div class="param-fuel"><span>D</span></div>
                                    <?}else{?>
                                    <div class="param-fuel"><span>B</span></div>   
                                    <?}?>

                            </li>

                        </ul>
                    </div>
                    <div class="itemCar-price-etc">
                        <div class="itemCar-price">

                            <strong>Supplement only:</strong> <strong>
                                <?
                                    $no_days = $this->session->userdata('no_days');

                                    //        Car price per day - and total
                                    switch($no_days){

                                        case $no_days<=3:
                                            $dayprice = $car_bigger[0]->day13price;
                                            break;

                                        case $no_days>=4 && $no_days<=7:
                                            $dayprice = $car_bigger[0]->day47price;
                                            break;

                                        case $no_days>=8 && $no_days<=15:
                                            $dayprice = $car_bigger[0]->day815price;
                                            break;
                                    }

                                    //Supplement calculate
                                    echo ($no_days*$dayprice)-($this->session->userdata('day_price')*$no_days);

                                ?>
                                &euro;</strong>

                        </div>
                        <div class="reservation">
                            <div class="submit">
                                <div class="submit-end">&nbsp;</div>
                                <a href="<?=$url?>step_3?id=<?=$car_bigger[0]->id?>">Change</a>
                            </div>
                        </div>
                    </div>
                </div>

            </fieldset>
        </div>
    </div>

    <?}?>

<script type="text/javascript">

    // Override default error message
    jQuery.validator.messages.required = "";

    // Override generation of error label
    $("#formReservationStep3").validate({
        rules: {
            name: "required",
            phone: "required",
            email: {
                required: true,
                email: true
            }
        },
        submitHandler: function(form) {
            if ($("#qf_f2eff2").is(":checked")){

                var that = jQuery('#formReservationStep3Submit').busy({ position : 'right', hide : false });
                $('#formReservationStep3Submit').attr('disabled','disabled');
                var form = $("#formReservationStep3");
                var form_data = form.serialize();
                //alert(form_data);
                $.ajax({
                    url: form.attr('action'),
                    dataType: 'json',
                    type: "POST",
                    data: form_data,
                    success: function (data, textStatus, xhr) {

                        if(data.response){
                            var id = data.json[0]['id'];
                            location.href = base_url+'show_order?id='+id;
                        }else{
                            alert(data.msg);                            
                        }
                        $('#formReservationStep3Submit').removeAttr('disabled');
                        that.busy("hide");
                    },
                    error: function (xhr, textStatus, errorThrown) {
                        alert('Error ocured...\n Server not found.');
                        $('#formReservationStep3Submit').removeAttr('disabled');
                        that.busy("hide");
                    }
                });

            }else{
                alert("Please correct the following information:\n\n- The field 'I agree with Terms and Conditions' is mandatory.\n\nThen re-submit the form.");
            }

        },
        errorPlacement: function(error, element){}
    });

    $('#formReservationStep3Submit').removeAttr('disabled');

</script>

<script type="text/javascript">
    $(function() {

        $('a[rel=lightbox]').lightBox({
            overlayBgColor: '#FFF',
            overlayOpacity: 0.6,
            imageLoading: base_url+'assets/img/lightbox/loading.gif',
            imageBtnClose: base_url+'assets/img/lightbox/close.gif',
            imageBtnPrev: base_url+'assets/img/lightbox/prev.gif',
            imageBtnNext: base_url+'assets/img/lightbox/next.gif',
            imageBlank : base_url+'assets/img/lightbox/blank.gif',
            containerResizeSpeed: 350,
            txtImage: 'Image',
            txtOf: 'of'
        });
    });
</script>